# makefile to build the binaries of cpe program
# Available make commands:
#       make            ->      build default binaries
#       make clean      ->      clean the binaries

.PHONY:clean

#Compiler
CC = gcc

# gcc options used for compiling
CFLAGS = -g -Wall -Wstrict-prototypes 

#source files path for test App
APP_SRC = src/cpe.c

#source files path for library
LIB_SRC = 

#Include directory
INC = inc/

#generating the executable
all:
	@echo -e "Available Targets:"
	@echo -e "\ttags       - Create ctags"
	@echo -e "\tcscope     - Create cscope"
	@echo -e "\tcpe        - Create cpe executable"
	@echo -e "\tclean      - Remove Executable and object files"
	@echo -e "\tdistclean  - Remove Executable, Object files, ctags, cscope and log files"

cpe:$(APP_SRC) $(LIB_SRC) $(INC)
	@sudo mkdir /var/log/cpe/ -p
	@$(CC) -c $(APP_SRC) $(LIB_SRC) $(CFLAGS) -I $(INC)
	@$(CC) -o $@ *.o
	@echo "CPE Target created successfully"

#cops_parser:$(LIB_SRC)
#	@$(CC) -c $(LIB_SRC) -I $(INC) $(CFLAGS) 
#	@ar -rcs lib_cops_parser.a cops_parser.o

tags:
	@ctags -R *
	@echo "Generating Ctags"

cscope:
	cscope -Rb
	@echo "Generating Cscope"

#remove object files, executable
clean:
	@sudo rm -f *.o cpe
	@echo "Cleaning Object files    .... Done"
	@echo "Cleaning Library         .... Done"
	@echo "Cleaning tags and cscope .... Done"

#remove object files, executable, tags, cscope and log files
distclean:
	@sudo rm -f *.o cpe tags cscope.out /var/log/cpe/*
	@echo "Cleaning Object files    .... Done"
	@echo "Cleaning Library         .... Done"
	@echo "Cleaning tags and cscope .... Done"
